<template>
  <view class="phxx-item-detail" style="padding-bottom: 0rpx">
    <view class="content-box">
      <view class="bottom block-back">
        <view class="title-box">基本信息<label class="edit-btn" @click="editFun(itemList.id)">编辑</label></view>
        <view class="line"></view>
        <view class="items">
          <text class="til col99">供应商名称</text>
          <text class="val col33">{{ itemList.cusName || '-' }}</text>
        </view>
        <view class="items">
          <text class="til col99">供应商简称</text>
          <text class="val col33">{{ itemList.supplierAbbreviation || '-' }}</text>
        </view>
        <view v-if="isShowERP" class="items">
          <text class="til col99">ERP供应商</text>
          <text class="val col33">{{ itemList.traderName || '-' }}</text>
        </view>
        <view class="items">
          <text class="til col99">统一社会信用代码</text>
          <text class="val col33">{{ itemList.cusSocial || '-' }}</text>
        </view>
        <view class="items">
          <text class="til col99">联系人</text>
          <text class="val col33">{{ itemList.contactPerson || '-' }}</text>
        </view>
        <view class="items">
          <text class="til col99">联系电话</text>
          <text class="val col33">{{ itemList.cusPhone || '-' }}</text>
        </view>
        <view class="items">
          <text class="til col99">企业类别</text>
          <text class="val col33">{{ cusTypeName || '-' }}</text>
        </view>
        <view class="items">
          <text class="til col99">结算类型</text>
          <text class="val col33">{{ settleName || '-' }}</text>
        </view>
        <view class="items">
          <text class="til col99">地址</text>
          <text class="val col33 adressBox">{{ itemList.address || '-' }}</text>
        </view>
      </view>
      <!-- <view class="bottom block-back">
        <view class="title-box">产品信息</view>
        <view class="line"></view>

        <view class="items-pro" v-for="items in itemList.productListBasicVOS" @click.stop="handleDetail(items.id)">
          <view class="til col99 width350">{{ items.proName }}</view>
          <view class="val col33">{{ items.proPrice + '元/吨' || '-'
            }}<uni-icons type="forward" size="20" v-if="!isDisabled"></uni-icons></view>
        </view>
      </view> -->
    </view>
  </view>
</template>

<script>
  import { toast } from '@/utils/common';
  import { getDetails } from '@/api/supplier.js';
  import { getDictList } from '@/api/login';
  import { getTenantId } from '@/utils/auth';
  import { getBasisDeploy } from "@/api/system/user.js"
  export default {
    data() {
      return {
        rowId: '',
        isShowERP: false,
        isMore: 'more',
        coalTypeList: [],
        productList: [],
        queryParam: {
          pageNo: 1,
          pageSize: 5
        },
        itemList: {
          id: undefined,
          cusName: undefined,
          cusPhone: undefined,
          supplierAbbreviation: undefined,
          cusSocial: undefined,
          cusProvince: undefined,
          cusCity: undefined,
          cusCounty: undefined,
          cusTown: undefined,
          regAddress: undefined,
          address: undefined,
          contactPerson: undefined,
          // productManagementBaseVOS: []
        },
        companyRange: [],
        cusTypeName: '',
        settleName: ''
      };
    },
    onLoad(options) {
      this.getBasisDeploy()
      if (!!options) {
        if (!!options.id) {
          this.getDetail(options.id);
        }
      }
    },
    methods: {
      async getBasisDeploy() {
        const res = await getBasisDeploy(getTenantId())
        if (res.code === '200') {
          this.isShowERP = res.data?.erpDocking === 0
        } else {
          toast(res.msg)
        }
      },
      handleDetail(id) {
        uni.navigateTo({
          url: `/packageB/pages/common/product-details/index?id=${id}`
        });
      },
      async getDetail(id) {
        let _ = this;
        let data = await getDetails(id);
        if (data.code == 0) {
          _.itemList = data.data;
          _.itemList.cusName = data.data.cusName;
          _.itemList.cusPhone = data.data.cusPhone;
          _.itemList.cusType = data.data.cusType;
          _.itemList.address = data.data.address;
          this.getDictLists(data.data.cusType);
          if (data.data.settlementNodeCode == 1) {
            _.settleName = '出矿过重';
          } else if (data.data.settlementNodeCode == 2) {
            _.settleName = '入厂过重';
          }
          // _.itemList.productListBasicVOS = data.data.productListBasicVOS || [];
        }
      },
      editFun(id) {
        uni.redirectTo({
          url: `/packageA/pages/common/supplier-editing/index?id=${id}`
        });
      },
      async getDictLists(type) {
        const res = await getDictList();
        if (res.code === 0) {
          this.companyRange = (res?.data || []).filter(
            (e) => e.dictType === 'enter_type'
          );
          this.companyRange.forEach((item) => {
            if (Number(item.value) == type) {
              this.cusTypeName = item.label;
            }
          });
        }
      }
    }
  };
</script>

<style lang="scss" scoped>
  .til {
    width: 201rpx !important;
  }

  .adressBox {
    white-space: normal;
    word-break: break-all;
    line-height: 40rpx;
    position: relative;
    top: 19rpx;
  }
</style>